 *Author AA
*Date 06/03/2025 


clear all


** Conditional Path Structure
*Ashani's Paths

if "`c(username)'" == "ashaniamarasinghe" & "`c(os)'"=="MacOSX" {
	global mainpath "/Users/ashaniamarasinghe/Dropbox/Youtube"
	}

if "`c(username)'" == "aama7224" & "`c(os)'"=="MacOSX" {
	global mainpath "/Users/aama7224/Dropbox/Youtube"
	}



global data "empirics/analysis/data"
global fig "empirics/analysis/fig"
global tab "empirics/analysis/tab"
global est "empirics/analysis/est"



cd $mainpath

set scheme plotplainblind
use $data/gid_month_panel.dta, clear
 
 
 
**********************************
**********sumstats****************
**********************************


**Table A2
sum var1pred_idw_pop_w_std  var1pred_idw_std AC_total_fatalities_pop_w AC_total_fatalities AC_d_battle_count_pop_w AC_d_battle_count AC_d_exprem_count_pop_w AC_d_exprem_count AC_d_protest_count_pop_w AC_d_protest_count AC_d_riot_count_pop_w AC_d_riot_count AC_d_civ_count_pop_w AC_d_civ_count crime_count_pop_w crime_count if var1pred_idw_pop_w_std!=. 
 
 
 


********************************************
**********robustness***********************
********************************************


*Table A3 - controlling for population

*Table A3 - A - ACLED 
gen ln_pop=ln(0.1+gid_pop)
reghdfe var1pred_idw_std AC_total_fatalities ln_pop , noabsorb nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A3_A.doc, replace addtext(Grid FE, No, Year FE, No, Month FE, No) dec(5)

reghdfe var1pred_idw_std AC_total_fatalities ln_pop, absorb(year) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A3_A.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, No) dec(5)

reghdfe var1pred_idw_std AC_total_fatalities ln_pop, absorb(year month) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A3_A.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)



*Table A3 - B - Homicides 

reghdfe var1pred_idw_std crime_count ln_pop , noabsorb nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A3_B.doc, replace addtext(Grid FE, No, Year FE, No, Month FE, No) dec(5)

reghdfe var1pred_idw_std crime_count ln_pop, absorb(year) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A3_B.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, No) dec(5)

reghdfe var1pred_idw_std crime_count ln_pop, absorb(year month) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A3_B.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)






*Table A4 - split sample analysis for low vs high population areas
sum ln_pop, d

/*                          ln_pop
-------------------------------------------------------------
      Percentiles      Smallest
 1%    -2.302585      -2.302585
 5%     3.198624      -2.302585
10%     5.059577      -2.302585       Obs              45,580
25%      7.81305      -2.302585       Sum of wgt.      45,580

50%     9.872736                      Mean           9.338692
                        Largest       Std. dev.      3.225849
75%     11.62416        16.1863
90%     12.80845        16.1863       Variance        10.4061
95%     13.40907        16.1863       Skewness      -1.146048
99%     14.57567        16.1863       Kurtosis        4.78788

*/

gen high_pop=0
replace high_pop=1 if ln_pop>9.872736
replace high_pop=. if gid_pop==.


*Table A4 - A - ACLED 
reghdfe var1pred_idw_std AC_total_fatalities, absorb(gid year month) cl(gid) nocons, if high_pop==1
outreg2   using $tab/Table_A4_A.doc, replace addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)

reghdfe var1pred_idw_std AC_total_fatalities, absorb(gid year month) cl(gid) nocons, if high_pop==0
outreg2   using $tab/Table_A4_A.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)


*Table A4 - B - Homicides
reghdfe var1pred_idw_std crime_count, absorb(gid year month) cl(gid) nocons, if high_pop==1
outreg2   using $tab/Table_A4_B.doc, replace addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)

reghdfe var1pred_idw_std crime_count, absorb(gid year month) cl(gid) nocons, if high_pop==0
outreg2   using $tab/Table_A4_B.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)





*Table A5 - estimates with no population weighting

*Table A5 - A - ACLED 
reghdfe var1pred_idw_std AC_total_fatalities, noabsorb nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A5_A.doc, replace addtext(Grid FE, No, Year FE, No, Month FE, No) dec(5)

reghdfe var1pred_idw_std AC_total_fatalities, absorb(gid) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A5_A.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, No) dec(5)

reghdfe var1pred_idw_std AC_total_fatalities, absorb(gid year) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A5_A.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)

reghdfe var1pred_idw_std AC_total_fatalities, absorb(gid year month) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A5_A.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)



*Table A5 - B - Homicides

reghdfe var1pred_idw_std crime_count, noabsorb cl(gid) nocons, if var1pred_idw_pop_w_std!=.
outreg2  using $tab/Table_A5_B.doc, replace addtext(Grid FE, No, Year FE, No, Month FE, No)

reghdfe var1pred_idw_std crime_count, absorb(gid) cl(gid) nocons, if var1pred_idw_pop_w_std!=.
outreg2  using $tab/Table_A5_B.doc, append addtext(Grid FE, Yes, Year FE, No, Month FE, No)

reghdfe var1pred_idw_std crime_count, absorb(gid year) cl(gid) nocons, if var1pred_idw_pop_w_std!=.
outreg2  using $tab/Table_A5_B.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, No)

reghdfe var1pred_idw_std crime_count, absorb(gid year month) cl(gid) nocons , if var1pred_idw_pop_w_std!=.
outreg2  using $tab/Table_A5_B.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes)




*Table A6 - controlling for marginalization

gen ln_marg_index_2020=ln(0.1+marg_index_2020)

*Table A6 - A - ACLED 
reghdfe var1pred_idw_std AC_total_fatalities ln_marg_index_2020 , noabsorb nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A6_A.doc, replace addtext(Grid FE, No, Year FE, No, Month FE, No) dec(5)

reghdfe var1pred_idw_std AC_total_fatalities ln_marg_index_2020, absorb(year) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A6_A.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, No) dec(5)

reghdfe var1pred_idw_std AC_total_fatalities ln_marg_index_2020, absorb(year month) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A6_A.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)

*Table A6 - B - Homicides
reghdfe var1pred_idw_std crime_count ln_marg_index_2020 , noabsorb nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A6_B.doc, replace addtext(Grid FE, No, Year FE, No, Month FE, No) dec(5)

reghdfe var1pred_idw_std crime_count ln_marg_index_2020, absorb(year) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A6_B.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, No) dec(5)

reghdfe var1pred_idw_std crime_count ln_marg_index_2020, absorb(year month) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A6_B.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)



*Table A7 - IHS transformed fatalities
*Table A7 - A - ACLED 
reghdfe var1pred_idw_pop_w_std ihs_AC_total_fatalities_pop_w,noabsorb cl(gid) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A7_A.doc, replace addtext(Grid FE, No, Year FE, No, Month FE, No) dec(5)

reghdfe var1pred_idw_pop_w_std ihs_AC_total_fatalities_pop_w, absorb(gid ) cl(gid) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A7_A.doc, append addtext(Grid FE, Yes, Year FE, No, Month FE, No) dec(5)

reghdfe var1pred_idw_pop_w_std ihs_AC_total_fatalities_pop_w, absorb(gid year ) cl(gid) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A7_A.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, No) dec(5)

reghdfe var1pred_idw_pop_w_std ihs_AC_total_fatalities_pop_w, absorb(gid year month) cl(gid) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A7_A.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)


*Table A7 - B - Homicides
reghdfe var1pred_idw_pop_w_std ihs_crime_count_pop_w,noabsorb cl(gid) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A7_B.doc, replace addtext(Grid FE, No, Year FE, No, Month FE, No) dec(5)

reghdfe var1pred_idw_pop_w_std ihs_crime_count_pop_w, absorb(gid ) cl(gid) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A7_B.doc, append addtext(Grid FE, Yes, Year FE, No, Month FE, No) dec(5)

reghdfe var1pred_idw_pop_w_std ihs_crime_count_pop_w, absorb(gid year ) cl(gid) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A7_B.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, No) dec(5)

reghdfe var1pred_idw_pop_w_std ihs_crime_count_pop_w, absorb(gid year month) cl(gid) nocons, if var1pred_idw_pop_w_std!=.
outreg2   using $tab/Table_A7_B.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)



*Table A8 - ACLED_fatalities by event type
reghdfe var1pred_idw_pop_w_std AC_d_battle_count_pop_w, absorb(gid year month) nocons
outreg2  using $tab/Table_A8.doc, replace addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)

reghdfe var1pred_idw_pop_w_std AC_d_exprem_count_pop_w, absorb(gid year month) nocons
outreg2  using $tab/Table_A8.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)

reghdfe var1pred_idw_pop_w_std AC_d_protest_count_pop_w, absorb(gid year month) nocons
outreg2  using $tab/Table_A8.docc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)

reghdfe var1pred_idw_pop_w_std AC_d_riot_count_pop_w, absorb(gid year month) nocons
outreg2  using $tab/Table_A8.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)

reghdfe var1pred_idw_pop_w_std AC_d_civ_count_pop_w, absorb(gid year month) nocons
outreg2  using $tab/Table_A8.doc, append addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes) dec(5)




**Table A9 - UCDP fatalities
 
reghdfe var1pred_idw_pop_w_std UCDP_total_fatalities_pop_w, noabsorb cl(gid) nocons
outreg2  using $tab/Table_A9.doc, dec(4) replace addtext(Grid FE, No, Year FE, No, Month FE, No)

reghdfe var1pred_idw_pop_w_std UCDP_total_fatalities_pop_w, absorb(gid) cl(gid) nocons
outreg2  using $tab/Table_A9.doc, dec(4) append addtext(Grid FE, Yes, Year FE, No, Month FE, No)

reghdfe var1pred_idw_pop_w_std UCDP_total_fatalities_pop_w, absorb(gid year) cl(gid) nocons
outreg2  using $tab/Table_A9.doc, dec(4) append addtext(Grid FE, Yes, Year FE, Yes, Month FE, No)

reghdfe var1pred_idw_pop_w_std UCDP_total_fatalities_pop_w, absorb(gid year month) cl(gid) nocons resid
outreg2 using $tab/Table_A9.doc, dec(4) append addtext(Grid FE, Yes, Year FE, Yes, Month FE, Yes)







